using System;
using Taimila.Entify.Attributes;

namespace Taimila.Entify.UnitTests
{
	[Entity]
	public class EntityWithEntityValidatorMethods : Entity
	{
		[EntityProperty(PersistentName = "Name1")]
		public string Name1
		{
			get;
			set;
		}
		
		[EntityProperty(PersistentName = "Name2")]
		public string Name2
		{
			get;
			set;
		}
		
		#pragma warning disable
		[EntityValidator]
		private ValidationError ValidateThatNameAreSame()
		{
			if(this.Name1.Equals(this.Name2))
			{
				return null;	
			}
			else
			{
				return new ValidationError(ValidationErrorReason.CustomError, null, "Names are not same!");
			}
		}
		
		[EntityValidator]
		private ValidationError ValidateThatNamesStartWithL()
		{
			if(this.Name1.StartsWith("L") && this.Name2.StartsWith("L"))
			{
				return null;	
			}
			else
			{
				return new ValidationError(ValidationErrorReason.CustomError, null, "One or both of the names didn't start with 'L'!");
			}
		}
		#pragma warning enable
	}
}
